//
//  AddServiceEvaluationViewController.m
//  CPICApp
//
//  Created by lizhiwei on 13-3-8.
//  Copyright (c) 2013年 lizhiwei. All rights reserved.
//

#import "AddServiceEvaluationViewController.h"
#import "RCAlertViewUtil.h"
#import "NSString+SBJson.h"
#import "Config.h"
#import "UIImageView+WebCache.h"
#import "OperationLogView.h"
#import "ASIFormDataRequest.h"
#import <QuartzCore/QuartzCore.h>
@interface AddServiceEvaluationViewController ()

@end

@implementation AddServiceEvaluationViewController
@synthesize Tableview;
@synthesize ListContent;
@synthesize ListTitle;
@synthesize SelEvaluationBtn;
@synthesize EvaluationModel;
@synthesize EvaSubmitBtn;
@synthesize txvFeedback;
@synthesize progress;
@synthesize evaluation;
@synthesize seriveitem;
@synthesize evaluatetime;
@synthesize Dissatisfied;
@synthesize seriveid;
@synthesize evaluateText;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
        self.title = @"服务评价";
        //self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg640X773@2x"]];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    NSUserDefaults *accountDefaults = [NSUserDefaults standardUserDefaults];
    NSString *bgimage= [accountDefaults objectForKey:@"UserDefaultBgKindKey"];
    
    if ([bgimage isEqualToString:@"蓝色主题风格"]) 
    {
        ADD_BACKGROUND_BUTTONITEM(@"icon640X88@2x.png");
        ADD_LEFT_BUTTONITEM(@"back.png");
        ADD_TITLE_NAMEITEM(@"服务评价");
        self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg640X773@2x"]];
    }
    else if([bgimage isEqualToString:@"棕色主题风格"])
    {
        ADD_BACKGROUND_BUTTONITEM(@"icon640X88_01@2x.png");
        ADD_LEFT_BUTTONITEM(@"back_01.png");
        ADD_TITLE_NAMEITEM(@"服务评价");
        self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg640X773_01@2x"]];
    }
    else if([bgimage isEqualToString:@"重大节日皮肤"])
    {
        NSData *dataImg_02=[[NSUserDefaults standardUserDefaults]objectForKey:SKIN_IMG_DATA_02];
        NSLog(@"-------找到%@",dataImg_02);
        NSData *dataImg_03=[[NSUserDefaults standardUserDefaults]objectForKey:SKIN_IMG_DATA_03];
        NSData *dataImg_04=[[NSUserDefaults standardUserDefaults]objectForKey:SKIN_IMG_DATA_04];
        
        NSURL *urlSkinImg_02=[NSURL URLWithString:[[NSUserDefaults standardUserDefaults]objectForKey:SKIN_IMG_URL_02]];
        NSURL *urlSkinImg_03=[NSURL URLWithString:[[NSUserDefaults standardUserDefaults]objectForKey:SKIN_IMG_URL_03]];
        NSURL *urlSkinImg_04=[NSURL URLWithString:[[NSUserDefaults standardUserDefaults]objectForKey:SKIN_IMG_URL_04]];
        NSLog(@"-------找到333%@",urlSkinImg_02);
        
        UIImageView * LogoImage = [[UIImageView alloc]init];
        [LogoImage setImageWithURL:urlSkinImg_03 success:^(UIImage *image)
         {
             NSData *imgData=UIImagePNGRepresentation(LogoImage.image);
             [[NSUserDefaults standardUserDefaults] setObject:imgData forKey:SKIN_IMG_DATA_03];
         } failure:^(NSError *error)
         {
             [self justShowMessage:@"更新皮肤失败!" title:@"提示"];
         }];
        
        LogoImage.image = [UIImage imageWithData:dataImg_03];
        LogoImage.frame = CGRectMake(0, 0, LogoImage.image.size.width/2, LogoImage.image.size.height/2);
        [self.view addSubview:LogoImage];
        
        //--------------------------
        UIButton * CallOutBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
        CallOutBtn1.frame = CGRectMake(10, 10, 109/2, 57/2);
        UIImageView * Back = [[UIImageView alloc]init];
        [Back setImageWithURL:urlSkinImg_02 success:^(UIImage *image)
         {
             NSData *imgData=UIImagePNGRepresentation(Back.image);
             [[NSUserDefaults standardUserDefaults] setObject:imgData forKey:SKIN_IMG_DATA_02];
         } failure:^(NSError *error)
         {
             [self justShowMessage:@"更新皮肤失败!" title:@"提示"];
         }];
        
        [Back setImage:[UIImage imageWithData:dataImg_02]];
        [CallOutBtn1 setImage:Back.image forState:UIControlStateNormal];
        [CallOutBtn1 addTarget:self action:@selector(ClickCallOutBtn) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:CallOutBtn1];
        //--------------------------
        
        ADD_TITLE_NAMEITEM(@"服务评价");
        
        
        UIImageView *bgimage = [[UIImageView alloc]initWithFrame:CGRectMake(0,44, self.view.frame.size.width, self.view.frame.size.height-44)];
        [bgimage setImageWithURL:urlSkinImg_04 success:^(UIImage *image)
         {
             NSData *imgData=UIImagePNGRepresentation(bgimage.image);
             [[NSUserDefaults standardUserDefaults] setObject:imgData forKey:SKIN_IMG_DATA_04];
         } failure:^(NSError *error)
         {
             [self justShowMessage:@"更新皮肤失败!" title:@"提示"];
         }];
        
        [bgimage setImage:[UIImage imageWithData:dataImg_04]];
        [self.view addSubview:bgimage];
        [bgimage release];
    }

    
    //self.seriveitem = [self.evaluation objectForKey:@"seriveItem"];
    self.evaluatetime=[self.evaluation objectForKey:@"evaluateTime"];
    //self.seriveid = [self.evaluation objectForKey:@"seriveItemId"];
    NSLog(@"---------%@",self.seriveitem);
    
    //添加UITableview
    Tableview = [[UITableView alloc] initWithFrame:CGRectMake(0.0f, 44.0f, self.view.frame.size.width, self.view.frame.size.height)style:UITableViewStyleGrouped];
    Tableview.backgroundColor = [UIColor clearColor];
	Tableview.delegate = self;
	Tableview.dataSource = self;
    
    Tableview.opaque = NO;
    Tableview.backgroundView = nil;
    Tableview.autoresizingMask = UIViewContentModeTop;
    Tableview.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
    //[Tableview reloadData];
	[self.view addSubview:Tableview];
    [Tableview release];
    
    ListContent = [[NSMutableArray alloc] init];
	[ListContent addObjectsFromArray:[NSArray arrayWithObjects:@"联系客服服务", @"2013-03-08", @"",@"", nil]];
    
    ListTitle = [[NSMutableArray alloc]init];
    [ListTitle addObjectsFromArray:[NSArray arrayWithObjects:@"评价项目",@"接受服务时间",@"服务评分",@"服务评论:",nil]];
    
    EvaluationModel = [[NSMutableArray alloc]initWithObjects:@"服务评论模板1",@"服务评论模板2",@"服务评论模板3",@"服务评论模板4",nil];
    
    //添加服务评价提交按钮
    EvaSubmitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [EvaSubmitBtn setImage:[UIImage imageNamed:@"Submit_suggestion"] forState:UIControlStateNormal];
    EvaSubmitBtn.frame = CGRectMake((self.view.frame.size.width-155)/2, 380, 155, 119/2);
    [EvaSubmitBtn addTarget:self action:@selector(EvaSubmit) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:EvaSubmitBtn];
    
    UILabel * lbSuggestion = [[UILabel alloc]initWithFrame:CGRectMake((self.view.frame.size.width-155)/2, 368, 155, 119/2)];
    lbSuggestion.text = @"提交";
    lbSuggestion.textAlignment = UITextAlignmentCenter;
    lbSuggestion.textColor = [UIColor whiteColor];
    lbSuggestion.backgroundColor = [UIColor clearColor];
    [self.view addSubview:lbSuggestion];
    [lbSuggestion release];
    
    ratingValue = @"5.0";
}

#pragma UITableViewDelegate

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

- (CGFloat)tableView:(UITableView *)atableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * kCellID = @"cellID";
	
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellID];
	if (cell == nil)
	{
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellID] autorelease];
        cell.accessoryType = UITableViewCellAccessoryNone;
        
        //设置选中某行的风格颜色
        cell.selectionStyle = UITableViewCellSelectionStyleBlue;
        cell.selectionStyle = UITableViewCellEditingStyleNone;
        
        UIView *view = [[UIView alloc] initWithFrame:cell.frame];
        
        UILabel *labelContent= [[UILabel alloc] init];
        [labelContent setText:[self.ListTitle objectAtIndex:indexPath.row]];
        [labelContent setFrame:CGRectMake(15, 0, 200, 50)];
        [labelContent setFont:[UIFont systemFontOfSize:13.0]];
        [labelContent setBackgroundColor:[UIColor clearColor]];
        
        if (indexPath.row == 0)
        {
            UILabel *labelDateTime = [[UILabel alloc] init];
            [labelDateTime setText:self.seriveitem];
            [labelDateTime setFrame:CGRectMake(130, 0, 200, 50)];
            [labelDateTime setFont:[UIFont systemFontOfSize:13.0]];
            [labelDateTime setBackgroundColor:[UIColor clearColor]];
            [view addSubview:labelDateTime];
            [labelDateTime release];
        }
        else if (indexPath.row == 1)
        {
            NSDate * senddate=[NSDate date];
            NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
            [dateformatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
            NSString * locationString=[dateformatter stringFromDate:senddate];
            NSLog(@"---------------%@",locationString);
            NSString * Evaluatetime = locationString;

            UILabel *labelDateTime = [[UILabel alloc] init];
            [labelDateTime setText:Evaluatetime];
            [labelDateTime setFrame:CGRectMake(130, 0, 200, 50)];
            [labelDateTime setFont:[UIFont systemFontOfSize:13.0]];
            [labelDateTime setBackgroundColor:[UIColor clearColor]];
            [view addSubview:labelDateTime];
            [labelDateTime release];
        }
        else if(indexPath.row == 3)
        {
            evaluateText = [[UILabel alloc] init];
            [evaluateText setText:@"请选择服务评论"];
            [evaluateText setFrame:CGRectMake(130, 0, 200, 50)];
            [evaluateText setFont:[UIFont systemFontOfSize:12.0]];
            [evaluateText setBackgroundColor:[UIColor clearColor]];
            [view addSubview:evaluateText];
            [evaluateText release];
        }
        
        SelEvaluationBtn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        SelEvaluationBtn.frame = CGRectMake(270, 10, 50, 30);
        [SelEvaluationBtn addTarget:self action:@selector(SelEvaluation) forControlEvents:UIControlEventTouchUpInside];
        
        if (indexPath.row == 2)
        {
            starView = [[RatingView alloc] initWithFrame:CGRectMake(130, 10, 200, 30)];
            [starView setImagesDeselected:@"UnEvaluation.png" partlySelected:@"" fullSelected:@"Evaluationed.png" andDelegate:self];
            [starView displayRating:5];
            [view addSubview:starView];
        }
        
        if (indexPath.row == 3)
        {
            [view addSubview:SelEvaluationBtn];
        }
        
        [view addSubview:labelContent];
        
        [labelContent release];
        
        [cell addSubview:view];
        [view release];
	}
    
	return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}


-(void) SelEvaluation
{
    [self setEvaluationTemplateRequest];
}

-(void)ClickItem:(NSString *)Title ActionSheetTag:(NSInteger)actionSheetTag
{
    
}

-(void)ClickItem:(NSString *)Title selectRow:(NSInteger)SelectRow ActionSheetTag:(NSInteger)actionSheetTag
{
    if (actionSheetTag == 0)
    {
        NSLog(@"======%@",EvaluationModel);
        if (EvaluationModel == nil) 
        {
            NSLog(@"99999999999999");
            evaluateText.text = @"";
            return;
        }
        else 
        {
            evaluateText.text = [EvaluationModel objectAtIndex:SelectRow];
        }
    }
}

-(void) EvaSubmit
{
     if ([ratingValue isEqualToString:@"1.0"])
     {
         if (txvFeedback.text.length==0) {
             [self justShowMessage:@"请填写不满意内容" title:@"注意"];
             return;
         }
     }
    [self setEvaluationSumbitRequest];
    //[self justShowMessage:@"服务评价提交成功!" title:@"提示"];
}

-(void) ClickCallOutBtn
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

-(void)ratingChanged:(float)newRating
{
	//ratingValue = [NSString stringWithFormat:@"%1.1f", newRating];
    ratingValue = [[NSString alloc]initWithFormat:@"%1.1f",newRating];
    NSLog(@"-----------%@",ratingValue);
    
    if ([ratingValue isEqualToString:@"1.0"])
    {
        Dissatisfied = [[UILabel alloc]initWithFrame:CGRectMake(10, 260, 100, 25)];
        Dissatisfied.text = @"不满意内容";
        Dissatisfied.font = [UIFont systemFontOfSize:14.0];
        Dissatisfied.backgroundColor = [UIColor clearColor];
        Dissatisfied.textColor = [UIColor lightGrayColor];
        [self.view addSubview:Dissatisfied];
        [Dissatisfied release];
        
        txvFeedback=[[UITextView alloc]initWithFrame:CGRectMake(10, 284, 300, 70)];
        txvFeedback.returnKeyType=UIReturnKeyDone;
        txvFeedback.delegate=self;
        txvFeedback.layer.borderColor = [UIColor grayColor].CGColor;
        txvFeedback.layer.borderWidth =1.0;
        txvFeedback.layer.cornerRadius =5.0;
        [self.view addSubview:txvFeedback];
        
        if (txvFeedback.text.length==0)
        {
            [self justShowMessage:@"请您留下宝贵意见!" title:@"提示"];
        }
    }
    else
    {
        [Dissatisfied removeFromSuperview];
        Dissatisfied = [[UILabel alloc]initWithFrame:CGRectMake(10, 260, 100, 25)];
        Dissatisfied.text = @"";
        Dissatisfied.font = [UIFont systemFontOfSize:14.0];
        Dissatisfied.backgroundColor = [UIColor clearColor];
        Dissatisfied.textColor = [UIColor whiteColor];
        [self.view addSubview:Dissatisfied];
        [Dissatisfied release];
        [txvFeedback setHidden:YES];
    }
}

- (void)textViewDidBeginEditing:(UITextView *)textView
{
    if(textView==txvFeedback)
    {
        [self SetAnimation:180];
    }
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
    if(textView==txvFeedback)
    {
        [self backAnimation:180];
    }
}

-(void)SetAnimation:(CGFloat)Xorigin
{
    NSTimeInterval animationDuration = 0.30f;
    CGRect frame = self.view.frame;
    //frame.origin.x+=Xorigin;
    frame.origin.y-=Xorigin;
    //frame.size.height +=Xorigin;
    self.view.frame = frame;
    [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
    [UIView setAnimationDuration:animationDuration];
    self.view.frame = frame;
    [UIView commitAnimations];
}

-(void)backAnimation:(CGFloat)Xorigin
{
    NSTimeInterval animationDuration = 0.30f;
    CGRect frame = self.view.frame;
    //frame.origin.x -=Xorigin;
    frame.origin.y+=Xorigin;
    //frame.size.height -=Xorigin;
    self.view.frame = frame;
    [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
    [UIView setAnimationDuration:animationDuration];
    self.view.frame = frame;
    [UIView commitAnimations];
    // [textField resignFirstResponder];
}

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    
    if ([@"\n" isEqualToString:text] == YES)
    {
        [textView resignFirstResponder];
        return NO;
    }
    
    return YES;
}

-(void)setEvaluationTemplateRequest//向太保移动平台发送请求报文
{
//    NSString *strRequestCode=@"RequestCode=31001";
    NSString *strRequestData=[NSString stringWithFormat:@"{\"serviceItem\":\"%@\",\"serviceItemId\":\"%@\"}",self.seriveitem,self.seriveid];
//    NSString *strUrl=[NSString stringWithFormat:@"%@%@%@",Server_Url,strRequestCode,strRequestData];
//    NSLog(@"++++++++++++++%@",strUrl);
//    strUrl = [strUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];//字符串编码转换
//    
//    NSURL *myurl = [NSURL URLWithString:strUrl];//This method expects URLString to contain any necessary percent escape codes, which are ‘:’, ‘/’, ‘%’, ‘#’, ‘;’, and ‘@’. Note that ‘%’ escapes are translated via UTF-8.
//    NSLog(@"URL:%@",myurl);
    ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:Server_Url_Form]];
    //设置需要POST的数据，这里提交两个数据，A=a&B=b
    [request setPostValue:@"31001" forKey:@"RequestCode"];
    [request setPostValue:strRequestData forKey:@"RequestData"];
   
    [request setDelegate:self];
    [request setDidFailSelector:@selector(ResponseFail:)];
    [request setDidFinishSelector:@selector(ResonseSuccess:)];
    [request startAsynchronous];
    
    showProgress = YES;
    if (showProgress)
    {
        progress= [[MBProgressHUD alloc]initWithView:self.view];
        [self.view addSubview:progress];
        [self.view bringSubviewToFront:progress];
        progress.labelText = @"加载中...";
        [progress show:YES];
        showProgress = NO;
    }
}

- (void)ResonseSuccess:(ASIHTTPRequest *)request
{
    if (!showProgress)
    {
        [progress removeFromSuperview];
        progress = nil;
    }
    
    NSString *responseString = [request responseString];
    NSLog(@"responseString %@",responseString);
    NSMutableDictionary *dictResponse=[responseString JSONValue];
    NSLog(@"dictResponse  %@",dictResponse);
    NSMutableDictionary *dictopinion=[dictResponse objectForKey:@"evaluateTemplateList"];
    arrTemplate=[dictopinion objectForKey:@"data"];
    
    [EvaluationModel removeAllObjects];
    for (int k = 0; k < [arrTemplate count]; k++)
    {
        NSMutableDictionary * Template = [arrTemplate objectAtIndex:k];
        NSString * ss=[[NSString alloc] initWithFormat:@"%@",[Template objectForKey:@"evaluteText"]];
        [EvaluationModel addObject:ss];
        //EvaluationModel = [arrTemplate objectAtIndex:0];
        NSLog(@"==========%@",ss);

    }
    NSLog(@"------%@",EvaluationModel);
    if ([EvaluationModel count]==0)
    {
        [self justShowMessage:@"获取的数据为空!" title:@"提示"];
        return;
    }
    
    CustomActionSheet *sheet=[[CustomActionSheet alloc]initWithHeight:284.0f WithSheetTitle:@"" WithDataArray:EvaluationModel];
    sheet.tag = 0;
    sheet.Customdelegate = self;
    [sheet showInView:self.view];
}

- (void)ResponseFail:(ASIHTTPRequest *)request
{
    if (!showProgress)
    {
        [progress removeFromSuperview];
        progress = nil;
    }
    
    NSLog(@"服务器连接失败!");
    [self justShowMessage:@"服务器连接失败！" title:@"提示"];
}

-(void)setEvaluationSumbitRequest//向太保移动平台发送请求报文
{
    NSLog(@"userinfodefault%@",[[NSUserDefaults standardUserDefaults] objectForKey:DICT_USER_INFO]);
    NSDictionary *dictUserInfo=[[NSUserDefaults standardUserDefaults] dictionaryForKey:DICT_USER_INFO];
    if (dictUserInfo!=nil) {
        if ([dictUserInfo valueForKey:@"UserAccount"]) {
            NSLog(@"%@",[dictUserInfo valueForKey:@"UserAccount"]);
        }
    }
    else
    {
        [self justShowMessage:@"用户还没登录,请登录系统" title:@"注意"];
        return;
    }
    
    NSString * userAccount = [dictUserInfo valueForKey:@"UserAccount"];
 //   NSString *strRequestCode=@"RequestCode=30901";
    NSLog(@"----------%@",ratingValue);
    NSString *strEvaluate=self.evaluateText.text;
    if (strEvaluate.length==0) {
        strEvaluate=@"";
    }
    NSString *strFeedback=self.txvFeedback.text;
    if (strFeedback.length==0) {
        strFeedback=@"";
    }
    NSString *strRequestData=[NSString stringWithFormat:@"{\"userAccount\":\"%@\",\"seriveItem\":\"%@\",\"evaluateTime\":\"%@\",\"score\":\"%@\",\"evaluateText\":\"%@\",\"ScoreText\":\"%@\"}",userAccount,self.seriveid,self.evaluatetime,ratingValue,strEvaluate,strFeedback];
    NSLog(@"服务评价提交请求报文体为%@",strRequestData);
//    NSString *strUrl=[NSString stringWithFormat:@"%@%@%@",Server_Url,strRequestCode,strRequestData];
//    
//    strUrl = [strUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];//字符串编码转换
//    
//    //NSURL *myurl = [NSURL URLWithString:strUrl];//This method expects URLString to contain any necessary percent escape codes, which are ‘:’, ‘/’, ‘%’, ‘#’, ‘;’, and ‘@’. Note that ‘%’ escapes are translated via UTF-8.
//    NSString *urlString = [NSString stringWithFormat:Server_Url_Form];
    ASIFormDataRequest *requestone = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:Server_Url_Form]];
    //设置需要POST的数据，这里提交两个数据，A=a&B=b
    [requestone setPostValue:@"30901" forKey:@"RequestCode"];
    [requestone setPostValue:strRequestData forKey:@"RequestData"];
    
    [requestone setDelegate:self];
    [requestone setDidFailSelector:@selector(ResponseFailone:)];
    [requestone setDidFinishSelector:@selector(ResonseSuccessone:)];
    [requestone startAsynchronous];
    
    showProgress = YES;
    if (showProgress)
    {
        progress= [[MBProgressHUD alloc]initWithView:self.view];
        [self.view addSubview:progress];
        [self.view bringSubviewToFront:progress];
        progress.labelText = @"加载中...";
        [progress show:YES];
        showProgress = NO;
    }
}

- (void)ResonseSuccessone:(ASIHTTPRequest *)requestone
{
    if (!showProgress)
    {
        [progress removeFromSuperview];
        progress = nil;
    }
    
    NSString *responseString = [requestone responseString];
    NSLog(@"responseString %@",responseString);
    NSMutableDictionary *dictResponse=[responseString JSONValue];
    NSMutableDictionary *jsonoSubObj = [dictResponse objectForKey:@"head"];
    NSString * ss = [[NSString alloc] initWithFormat:@"%@",[jsonoSubObj objectForKey:@"success"]];
    if ([ss isEqualToString:@"1"])
    {
        //[self justShowMessage:@"提交成功！" title:@"提示"];
        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"提交服务评价成功！" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alertView show];
        alertView.delegate = self;
        [alertView release];
        
        NSString *Code =@"30901";
        NSUserDefaults *accountDefaults = [NSUserDefaults standardUserDefaults];
        NSString * serialNostr=[accountDefaults objectForKey:@"OPERATIONLOG"]; 
        OperationLogView *operationlog =[[OperationLogView alloc]initView:Code withtype:@"2" withserialno:serialNostr];
        [operationlog setOperationLogRequest];
        [operationlog setHidden:YES];
        [self.view addSubview:operationlog];
        [operationlog release];
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
    else
    {
        [self justShowMessage:@"提交服务评价失败！" title:@"提示"];
    }
}

- (void)ResponseFailone:(ASIHTTPRequest *)requestone
{
    if (!showProgress)
    {
        [progress removeFromSuperview];
        progress = nil;
    }
    
    NSLog(@"服务器连接失败!");
    [self justShowMessage:@"服务器连接失败！" title:@"提示"];
}

-(id)initView:(NSString *)serviceID withserviceName:(NSString *)serviceName;
{
    self.seriveid = serviceID;
    self.seriveitem = serviceName;
    self = [super init];
    
    return self;
}


-(void) viewDidUnload
{
    [EvaSubmitBtn release];
    [starView release];
    [progress release];
    [arrTemplate release];
    [evaluation release];
    [evaluatetime release];
    [seriveitem release];
    [Dissatisfied release];
    [seriveid release];
    [evaluateText release];
    [ArrayTemplate release];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
